import request from '@/utils/request'

// 查询销项发票列表
export function listInvoice(query) {
  return request({
    url: '/doc/invoice/list',
    method: 'get',
    params: query
  })
}


// 查询销项发票详细
export function getInvoice(id) {
  return request({
    url: '/doc/invoice/' + id,
    method: 'get'
  })
}


// 查询销项发票详细(带发票信息)
export function getInvoiceFullInfo(id) {
  return request({
    url: '/doc/invoice/fullInfo/' + id,
    method: 'get'
  })
}

// 查询销项发票详细
export function getNextInvoice(id, searchType) {
  return request({
    url: '/doc/invoice/next/'+ searchType +'/' + id,
    method: 'get'
  })
}

// 查询销项发票详细
export function getPreInvoice(id, searchType) {
  return request({
    url: '/doc/invoice/pre/'+ searchType +'/' + id,
    method: 'get'
  })
}

// 新增销项发票
export function addInvoice(data) {
  return request({
    url: '/doc/invoice',
    method: 'post',
    data: data
  })
}

// 修改销项发票
export function updateInvoice(data) {
  return request({
    url: '/doc/invoice',
    method: 'put',
    data: data
  })
}


// 删除销项发票
export function delInvoice(id) {
  return request({
    url: '/doc/invoice/' + id,
    method: 'delete'
  })
}

// 同步发票
export function syncInvoice(id) {
  return request({
    url: '/doc/invoice/sync/' + id,
    method: 'get'
  })
}

// 开票销项发票
export function issueInvoice(id) {
  return request({
    url: '/doc/invoice/issue/' + id,
    method: 'get'
  })
}


// 删除进项发票
export function redInvoice(params) {
  return request({
    url: '/doc/invoice/red',
    method: 'get',
    params: params
  })
}

// 填开发票
export function writeInvoice(data) {
  return request({
    url: '/doc/invoice/write',
    method: 'put',
    data: data
  })
}
